package cn.lger.icollege.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Set;

/**
 * Code that Changed the World
 * Pro said
 * Created by Pro on 2018-04-14.
 */
@Entity
@Setter
@Getter
@JsonIgnoreProperties({"hibernateLazyInitializer","handler"})
public class Teacher implements Serializable {

    @Transient
    public final static String role = Role.TEACHER.name();

    @Id
    private String username; // 用户名、账号

    private String iconPath = "icon/common.jpg";

    @Column(nullable = false)
    @JsonIgnore
    private String password;

    @Column(length = 60, nullable = false)
    private String name; // 姓名

    @ManyToMany(mappedBy = "teachers",fetch = FetchType.EAGER)
    private Set<Classroom> classrooms;

    @OneToMany(mappedBy = "teacher")
    @JsonIgnore
    private Set<AttendanceRecord> attendanceRecords;

    private String address;

    private String phone;

    @Column(columnDefinition = "Integer default 0")
    private int news;//有没有新消息

    @OneToMany(cascade = CascadeType.REMOVE, mappedBy = "teacher")
    @JsonIgnore
    private Set<Notice> notices;

    public String getRole() {
        return role;
    }
}
